#@layout()
#define css()
#@layout_css?()
<link rel="stylesheet" href="#(CPATH)/static/components/datepicker/css/bootstrap-datepicker3.min.css">
#end
#define script()
#@layout_script?()
<script src="#(CPATH)/static/components/datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="#(CPATH)/static/components/datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script>
    $("input[hint='date']").datepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN'
    });

    function doSubmit() {
        ajaxSubmit("#form", function (data) {
            $("#entryId").attr("value", data.id);
            toastr.success('内容保存成功。');
        })
    }

    $("#submit").on("click", function () {
        doSubmit();
    })


</script>
#end

#define content()

<section class="content-header">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">

                <div class="row mb-2">
                    <div class="col-sm-12">
                        <h1>
                            #(formInfo ? '编辑' : '新增')表单
                            <small data-toggle="tooltip" title="" data-placement="right"
                                   data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                            <small> 首页 / 表单 / #(formInfo ? '编辑' : '新增')表单</small>
                        </h1>
                    </div>
                </div>
            </div>
        </div>

    </div><!-- /.container-fluid -->
</section>

<section class="content">
    <div class="row">
        <div class="col-12">
            <div class="card card-outline card-primary">
                <form class=" form-setting" autocomplete="off"
                      action="#(CPATH)/admin/form/doSave"
                      method="POST" id="form">

                    <div class="card-body ">
                        <input type="hidden" id="entryId" name="formInfo.id" value="#(formInfo.id ??)">

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单名称</label>
                            <div class="col-sm-6">

                                <input type="text" name="formInfo.name" class="form-control"
                                       value="#(formInfo.name ??)"
                                       placeholder="请输入名称">
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单标题（前台显示）</label>
                            <div class="col-sm-6">

                                <input type="text" name="formInfo.title" class="form-control"
                                       value="#(formInfo.title ??)"
                                       placeholder="表单标题">
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单描述（前台显示）</label>
                            <div class="col-sm-6">
                                <textarea name="formInfo.summary" class="form-control"
                                          rows="3" placeholder="...">#(formInfo.summary ??)</textarea>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单标识</label>
                            <div class="col-sm-6">

                                <input type="text" name="formInfo.flag" class="form-control"
                                       value="#(formInfo.flag ??)"
                                       placeholder="请输入标识">
                            </div>
                        </div>


                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单背景图</label>
                            <div class="col-sm-9">
                                <div class="jpress-image-browser">
                                    <input type="hidden" name="formInfo.bg_image" value="#(formInfo.bg_image ??)"/>
                                    <img src="#(formInfo.bg_image ?? '/static/commons/img/nothumbnail.jpg')">
                                    <div class="image-action">
                                        <a class="image-delete"> <i class="fa fa-trash"></i></a>
                                        <a class="image-edit"> <i class="fa fa-edit"></i></a>
                                    </div>
                                </div>
                                <p class="text-muted"></p>

                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">表单头图</label>
                            <div class="col-sm-9">
                                <div class="jpress-image-browser">
                                    <input type="hidden" name="formInfo.header_image"
                                           value="#(formInfo.header_image ??)"/>
                                    <img src="#(formInfo.header_image ?? '/static/commons/img/nothumbnail.jpg')">
                                    <div class="image-action">
                                        <a class="image-delete"> <i class="fa fa-trash"></i></a>
                                        <a class="image-edit"> <i class="fa fa-edit"></i></a>
                                    </div>
                                </div>
                                <p class="text-muted"></p>

                            </div>
                        </div>


                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="offset-sm-2 col-sm-10 submit-block">
                            <div class="card-submit">
                                <button id="submit" type="button" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </form>
            </div>
        </div>
    </div>

</section>

#end
